package jok.list;

import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;

public class ListDemo {

	public static void main(String[] args) {

		List list = new ArrayList();

		list.add(new Student(1, "张三", 1));
		list.add(new Student(2, "李四", 1));
		list.add(new Student(3, "王五", 2));

		for (int i = 0; i < list.size(); i++) {
			Student stu = (Student) list.get(i);
			System.out.println(stu);
		}

		System.out.println("-----------------");

		List<Student> list2 = new ArrayList<Student>();

		list2.add(new Student(1, "张三", 1));
		list2.add(new Student(2, "李四", 1));
		list2.add(new Student(3, "王五", 2));

		ListIterator<Student> iter = list2.listIterator();

		while (iter.hasNext()) {
			Student stu = iter.next();
			System.out.println(stu);
		}

		System.out.println("-----------------");

		for (Student stu : list2) {
			System.out.println(stu);
		}
	}
}
